<?

class AjaxController extends Controller {
    
    public function loginAction($user,$password){
        $connect = $this->connections;
        
        
        $return["response_code"] = "ok";
        $return["login"] = $connect->exists("users",array("username"=>$user,"password"=>$password));
        
        if($return["login"]) {
        	
        	$user = $connect->fetchModels("Users",array("username"=>$user));
            $_SESSION["logged"] = true;
            $_SESSION["username"] = $user->username;
            $_SESSION["user_id"] = $user->_id;
            $_SESSION["societe_name"] = $user->raison_social;
        }
        return json_encode($return);
    }
}
?>